package com.hmall.api;


import com.hmall.dto.CartFormDTO;
import com.hmall.vo.CartVO;
import feign.Param;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;

@FeignClient("cart-service")
public interface CartClient {

    @ApiOperation("添加商品到购物车")
    @PostMapping("/carts")
    void addItem2Cart(@Valid @RequestBody CartFormDTO cartFormDTO);

    @ApiOperation("删除购物车中商品")
    @DeleteMapping("/carts/{id}")
    void deleteCartItem(@Param ("购物车条目id")@PathVariable("id") Long id);

    @ApiOperation("查询购物车列表")
    @GetMapping("/carts")
    List<CartVO> queryMyCarts();

    @ApiOperation("批量删除购物车中商品")
    @ApiImplicitParam(name = "ids", value = "购物车条目id集合")
    @DeleteMapping("/carts")
    void deleteCartItemByIds(@RequestParam("ids") Collection<Long> ids);
}
